const { sequelize } = require('../config/db');
const { DataTypes } = require('sequelize');

const HealthArticle = sequelize.define('HealthArticle', {
  id: {
      type: DataTypes.INTEGER,
      primaryKey: true,
      autoIncrement: true
    },
    title: {
      type: DataTypes.STRING(255),
      allowNull: false
    },
    content: {
      type: DataTypes.TEXT('long'),
      allowNull: false
    },
    categoryId: {
      type: DataTypes.STRING(50),
      field: 'category_id',
      allowNull: false
    },
    categoryName: {
      type: DataTypes.STRING(50),
      field: 'category_name',
      allowNull: false
    },
    publishDate: {
      type: DataTypes.DATEONLY,
      field: 'publish_date',
      allowNull: false
    },
    imageUrl: {
      type: DataTypes.STRING(255),
      field: 'image_url'
    }
  }, {
    tableName: 'health_articles',
    timestamps: true
});


// 导出所有模型
module.exports = { HealthArticle };